﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IDAL;

namespace BLL
{
    public class UserInfo
    {
        private static readonly IUserInfo daluser = DALFactory.DataAccess.CreateUserInfo();
        /// <summary>
        /// 用户登录验证
        /// </summary>
        /// <param name="username">用户名</param>
        /// <param name="password">密码</param>
        /// <param name="message">提示信息</param>
        /// <returns>是否成功</returns>
        public static bool Login(string username,string password ,ref string message) 
        {
            Model.UserInfo moduser=daluser.GetUserInfoByUserName(username);
            if (moduser == null) {
                message="该用户不存在!";
               
            }else if(moduser.Password!=password)
            {
                message="密码输入有误!";
            }
            else if (moduser.Password == password)
            {
                message = moduser.UID.ToString();
                return true;
            }
            else {
                message = "系统发生正忙请稍后重试!";
            }

            return false;
        }

        public static Model.UserInfo GetUserInfo(string username) {
            return daluser.GetUserInfoByUserName(username);
        }
    }
}
